package yur.wedding.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;


import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import yur.wedding.modules.sys.entity.SysDocdetailLogEntity;
import yur.wedding.modules.sys.service.SysDocdetailLogService;
import yur.wedding.utils.PageUtils;
import yur.wedding.utils.R;
import yur.wedding.validator.ValidatorUtils;


/**
 * 文档日志
 *
 * @author Yur
 * @email ${email}
 * @date 2022-08-16 07:31:41
 */
@RestController
@RequestMapping("sys/sysdocdetaillog")
public class SysDocdetailLogController {
    @Autowired
    private SysDocdetailLogService sysDocdetailLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:sysdocdetaillog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysDocdetailLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:sysdocdetaillog:info")
    public R info(@PathVariable("id") Long id){
        SysDocdetailLogEntity sysDocdetailLog = sysDocdetailLogService.getById(id);

        return R.ok().put("sysDocdetailLog", sysDocdetailLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:sysdocdetaillog:save")
    public R save(@RequestBody SysDocdetailLogEntity sysDocdetailLog){
        sysDocdetailLogService.save(sysDocdetailLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:sysdocdetaillog:update")
    public R update(@RequestBody SysDocdetailLogEntity sysDocdetailLog){
        ValidatorUtils.validateEntity(sysDocdetailLog);
        sysDocdetailLogService.updateById(sysDocdetailLog);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:sysdocdetaillog:delete")
    public R delete(@RequestBody Long[] ids){
        sysDocdetailLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


    /**
     * 获取单个文档有那些日志
     */
    @RequestMapping("/docdetaillogList/{dbgyId}")
    @RequiresPermissions("sys:sysdocdetaillog:docdetaillogList")
    public R docdetaillogList(@PathVariable("dbgyId") Long dbgyId,@RequestParam Map<String, Object> params) {

        PageUtils page = sysDocdetailLogService.getlogList(dbgyId,params);
        return R.ok().put("page", page);
    }

}
